Skip to content

Custom logger for Swarming & Removes circular dependency at logs.py#5247

Open
IvanBM18 wants to merge 4 commits intomasterfrom
feature/swarming/improve-logging
Open

Custom logger for Swarming & Removes circular dependency at logs.py#5247
IvanBM18 wants to merge 4 commits intomasterfrom
feature/swarming/improve-logging

Conversation

@IvanBM18
Copy link
Copy Markdown
Collaborator

@IvanBM18 IvanBM18 commented Apr 17, 2026

Currently swarming bots use the K8s default logging configurations(which work fine :D), but when we try to find logs specific to a given swarming bot host or a swarming task, things start to get complicated, its hard to pinpoint the execution workflow.

In this PR we changed the configuration so the logger can displays different information if its running on swarming.

Note: This PR is complimentary to this other pr

Tests performed

I launched some fuzzing jobs that executed in swarming, thanks to the new fields i was able to easily find the logs for a given bot or a given task. See example

@IvanBM18 IvanBM18 requested a review from letitz April 17, 2026 00:17
@IvanBM18 IvanBM18 marked this pull request as ready for review April 17, 2026 00:17
@IvanBM18 IvanBM18 requested a review from a team as a code owner April 17, 2026 00:17
Comment thread src/clusterfuzz/_internal/metrics/logs.py Outdated
Comment thread src/clusterfuzz/_internal/system/environment.py Outdated
Comment thread src/clusterfuzz/_internal/metrics/logs.py Outdated
Comment thread src/clusterfuzz/_internal/metrics/logs.py
Comment thread src/clusterfuzz/_internal/metrics/logs.py Outdated
Comment thread src/clusterfuzz/_internal/metrics/logs.py Outdated
Comment thread src/clusterfuzz/_internal/metrics/logs.py Outdated
Comment thread src/clusterfuzz/_internal/tests/core/bot/tasks/utasks/utasks_test.py Outdated
Comment thread src/clusterfuzz/_internal/tests/core/metrics/logs_test.py Outdated
Comment thread src/clusterfuzz/_internal/tests/core/metrics/logs_test.py Outdated
@IvanBM18 IvanBM18 self-assigned this Apr 17, 2026
@IvanBM18 IvanBM18 added the swarming Changes related to the clusterfuzz-swarming integration label Apr 17, 2026

def is_tworker():
return get_value('TWORKER', False)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for reviews:
To remove a circular dependency between logs.py and environment.py we moved this method into run_bot.py, this method required the logs module hence causing a circular dependency. Its safe to remove it from here as this was really only used at run_bot.py

return stacktrace, clean_exit, task_payload


def update_task_enabled() -> bool:
Copy link
Copy Markdown
Collaborator Author

@IvanBM18 IvanBM18 Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See context at context for this change at this comment and this other comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention this change in the PR description (which will become the commit message).

Copy link
Copy Markdown
Collaborator

@letitz letitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently swarming bots use the K8s default logging configurations(which work fine :D), but when we try to find logs specific to a given swarming bot host or a swarming task, things start to get complicated, its hard to pinpoint the execution workflow.

In this PR we changed the configuration so the logger can displays different information if its running on swarming.

This is vague. Please mention what is actually changing:

  • new metadata fields on logs
  • dropped metadata fields
  • any other behavioral changes from the PR
  • any refactorings done along the way

LGTM otherwise to avoid blocking on me further, but please resolve comments before landing.

not _is_running_on_app_engine() and not _is_running_on_k8s())
This is enabled by default but disabled for local development."""
return environment.get_value('LOG_TO_GCP',
True) and (not os.getenv('PY_UNITTESTS') and
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: I would move this PY_UNITTESTS check to its own helper method in environment.py: is_running_unit_tests().

Comment thread src/clusterfuzz/_internal/metrics/logs.py Outdated
Comment thread src/clusterfuzz/_internal/metrics/logs.py
return stacktrace, clean_exit, task_payload


def update_task_enabled() -> bool:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention this change in the PR description (which will become the commit message).

@IvanBM18 IvanBM18 changed the title Swarming: Improves logging for swarming bots Custom Logger for Swarming & Removes circular dependency at logs.py Apr 21, 2026
@IvanBM18
Copy link
Copy Markdown
Collaborator Author

IvanBM18 commented Apr 21, 2026

Currently swarming bots use the K8s default logging configurations(which work fine :D), but when we try to find logs specific to a given swarming bot host or a swarming task, things start to get complicated, its hard to pinpoint the execution workflow.
In this PR we changed the configuration so the logger can displays different information if its running on swarming.

This is vague. Please mention what is actually changing:

  • new metadata fields on logs
  • dropped metadata fields
  • any other behavioral changes from the PR
  • any refactorings done along the way

LGTM otherwise to avoid blocking on me further, but please resolve comments before landing.

Sure i'll do that, thanks for the feedback :D

Co-authored-by: Titouan Rigoudy <titouan@chromium.org>
@IvanBM18 IvanBM18 changed the title Custom Logger for Swarming & Removes circular dependency at logs.py Custom logger for Swarming & Removes circular dependency at logs.py Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

swarming Changes related to the clusterfuzz-swarming integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants